import request from '@/utils/request'
import type { TenantVo, TenantQuery, TenantForm } from '@/types/system/tenant'

// 获取租户列表
export function listTenant(query: TenantQuery) {
  return request({
    url: '/system/tenant/list',
    method: 'get',
    params: query,
  })
}

// 新增租户
export function addTenant(data: TenantForm) {
  return request({
    url: '/system/tenant',
    method: 'post',
    data,
  })
}

// 修改租户
export function updateTenant(data: TenantVo) {
  return request({
    url: '/system/tenant',
    method: 'put',
    data,
  })
}

// 删除租户
export function deleteTenant(id: string) {
  return request({
    url: `/system/tenant/${id}`,
    method: 'delete',
  })
}

// 生成AppSecret
export function generateSecret() {
  return request<string>({
    url: '/system/tenant/generateSecret',
    method: 'get',
  })
}

// 重置管理员密码
export function resetPassword(id: string, password: string) {
  return request({
    url: `/system/tenant/resetPassword/${id}`,
    method: 'put',
    data: { password },
  })
}
